package com.xyht.medicine_management_system.modules.medicineSource.controller;


import com.xyht.medicine_management_system.common.commonReturn.ResponseResult;
import com.xyht.medicine_management_system.modules.medicineSource.entity.req.MmsMedicineSourceMedicineRelationReq;
import com.xyht.medicine_management_system.modules.medicineSource.entity.req.MmsMedicineSourceReq;
import com.xyht.medicine_management_system.modules.medicineSource.service.MmsMedicineSourceMedicineRelationService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 药知源与商品关联表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-12-05
 */
@RestController
@RequestMapping("/medicineSource/relation")
public class MmsMedicineSourceMedicineRelationController {
    @Resource
    private MmsMedicineSourceMedicineRelationService mmsMedicineSourceMedicineRelationService;

    @PostMapping("/add")
    @ApiModelProperty(value = "药知源与药品关系添加")
    public ResponseResult addRelation(@RequestBody MmsMedicineSourceMedicineRelationReq relationReq) {
        return mmsMedicineSourceMedicineRelationService.addRelation(relationReq);
    }

    @PostMapping("/delete")
    @ApiModelProperty(value = "药知源与药品关系删除")
    public ResponseResult deleteRelation(@RequestBody MmsMedicineSourceMedicineRelationReq relationReq) {
        return mmsMedicineSourceMedicineRelationService.deleteRelation(relationReq);
    }

    @GetMapping("/list")
    @ApiModelProperty(value = "药知源与药品关系列表")
    public ResponseResult getMedicineSourceList(@RequestParam("idType") Integer idType,
                                                @RequestParam("id") String id) {
        return mmsMedicineSourceMedicineRelationService.getRelationList(id,idType);
    }
}

